package cn.kgc.springboot1048.spring_vue2.service.impl;

import cn.kgc.springboot1048.spring_vue2.entity.Houseinfo;
import cn.kgc.springboot1048.spring_vue2.mapper.HouseinfoMapper;
import cn.kgc.springboot1048.spring_vue2.service.HouseinfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author szz
 * @since 2024-04-10
 */
@Service
public class HouseinfoServiceImpl extends ServiceImpl<HouseinfoMapper, Houseinfo> implements HouseinfoService {

    @Resource
    HouseinfoMapper houseinfoMapper;

    @Override
    public PageInfo<Houseinfo> selectAll(String desc, Integer pageSize, Integer pageIndex) {
        PageHelper.startPage(pageIndex,pageSize);
        List<Houseinfo> houseinfos = houseinfoMapper.selectAll(desc);
        PageInfo<Houseinfo> pageInfo=new PageInfo<>(houseinfos);
        return pageInfo;
    }

    @Override
    public int del(Integer Id) {
        return houseinfoMapper.delByHouseIdInt(Id);
    }

    @Override
    public int add(Houseinfo houseinfo) {
        return houseinfoMapper.add(houseinfo);
    }

    @Override
    public Houseinfo selectById(Integer Id) {
        return houseinfoMapper.selectById(Id);
    }

    @Override
    public boolean updateByHouse(Houseinfo houseinfo) {
        return houseinfoMapper.updateByHouse(houseinfo);
    }

    @Override
    public List<Houseinfo> selectByDesc(String desc) {
        return houseinfoMapper.selectAll(desc);
    }
}
